package com.citicup.backend.service.FundService;

import com.citicup.backend.entity.FundDaily;
import com.citicup.backend.entity.FundInfo;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Comparator;

public class FundSortInfo {
    @Getter
    FundInfo fundInfo;
    @Getter
    FundDaily fundDaily;

    ArrayList<Integer> ranks = new ArrayList<>();

    public FundSortInfo(FundInfo fundInfo, FundDaily fundDaily) {
        this.fundInfo = fundInfo;
        this.fundDaily = fundDaily;

    }

    public int rankSum() {
        int sum = 0;
        for (Integer i : ranks) {
            sum += i;
        }
        return sum;
    }

    static class FundSortInfoComparator implements Comparator<FundSortInfo> {
        @Override
        public int compare(FundSortInfo o1, FundSortInfo o2) {
            return Integer.compare(o1.rankSum(), o2.rankSum());
        }
    }
}
